package com.fh.shop.api.cate.controller;

import com.fh.shop.api.annotation.NeedLogin;
import com.fh.shop.api.cate.biz.ICateService;
import com.fh.shop.api.common.ServerResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/cates")
@Api(tags = "电商前台-分类接口")
public class CateController {

    private static final Logger LOGGER = LoggerFactory.getLogger(CateController.class);

    @Resource(name = "cateService")
    private ICateService cateService;

    @GetMapping
    @NeedLogin
    @ApiOperation("获取分类列表-登录后才能访问")
    @ApiImplicitParam(name = "x-auth", value = "登录后的头信息", required = true, dataType = "java.lang.String", paramType = "header")
    public ServerResponse list() {
        LOGGER.info("执行cate中的list方法");
        return cateService.findList();
    }
}
